﻿/*
 * 
 * Description: Office COMAddins Connector main dlg
 */
#ifndef OCC_MAIN_DLG_H
#define OCC_MAIN_DLG_H

#include <functional>
#include <string>
#include <unordered_map>
#include "CCOMAddIns.h"
#include "constant.h"

class OfficeCOMAddinConnectorDlg : public CDialogEx {
public:
    explicit OfficeCOMAddinConnectorDlg(CWnd *pParent = nullptr);
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_OCCONNECTOR_DIALOG };
#endif

protected:
    virtual void DoDataExchange(CDataExchange *pDX);

protected:
    HICON m_hIcon;
    virtual BOOL OnInitDialog();
    afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    DECLARE_MESSAGE_MAP()

    bool WaitForDocWindow(const char *mainWndText, const char *docWndText, CComPtr<IDispatch> &spDisp);
    void ConnectCOMAddIn(CCOMAddIns &addins, const std::string &comAddinName);
    void ConnectWordCOMAddIn();
    void ConnectExcelCOMAddIn();
    void ConnectPowerPointCOMAddIn();
    bool SplitLastArgument(std::string &cmdline, std::string &lastArgument);
    bool GetArguments(std::string &appName, std::string &comAddinName);

public:
    afx_msg void OnBnClickedButtonConnectComaddin();

private:
    std::string appName_ = CONSTANT::TEXT_DEFAULT;
    std::string comAddinName_ = CONSTANT::TEXT_DEFAULT;
};

#endif  // !OFFICE_ADDIN_CONNECTOR_DLG_H